package com.newMedical.medical.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.newMedical.common.annotation.Log;
import com.newMedical.common.core.controller.BaseController;
import com.newMedical.common.core.domain.AjaxResult;
import com.newMedical.common.enums.BusinessType;
import com.newMedical.medical.domain.HzMedical;
import com.newMedical.medical.service.IHzMedicalService;
import com.newMedical.common.utils.poi.ExcelUtil;
import com.newMedical.common.core.page.TableDataInfo;

/**
 * 病历表Controller
 * 
 * @author zhou
 * @date 2021-11-30
 */
@RestController
@RequestMapping("/medical/Medical")
public class HzMedicalController extends BaseController
{
    @Autowired
    private IHzMedicalService hzMedicalService;

    /**
     * 查询病历表列表
     */
    @PreAuthorize("@ss.hasPermi('medical:Medical:list')")
    @GetMapping("/list")
    public TableDataInfo list(HzMedical hzMedical)
    {
        startPage();
        List<HzMedical> list = hzMedicalService.selectHzMedicalList(hzMedical);
        return getDataTable(list);
    }

    /**
     * 导出病历表列表
     */
    @PreAuthorize("@ss.hasPermi('medical:Medical:export')")
    @Log(title = "病历表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HzMedical hzMedical)
    {
        List<HzMedical> list = hzMedicalService.selectHzMedicalList(hzMedical);
        ExcelUtil<HzMedical> util = new ExcelUtil<HzMedical>(HzMedical.class);
        util.exportExcel(response, list, "病历表数据");
    }

    /**
     * 获取病历表详细信息
     */
    @PreAuthorize("@ss.hasPermi('medical:Medical:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(hzMedicalService.selectHzMedicalById(id));
    }

    /**
     * 新增病历表
     */
    @PreAuthorize("@ss.hasPermi('medical:Medical:add')")
    @Log(title = "病历表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HzMedical hzMedical)
    {
        return toAjax(hzMedicalService.insertHzMedical(hzMedical));
    }

    /**
     * 修改病历表
     */
    @PreAuthorize("@ss.hasPermi('medical:Medical:edit')")
    @Log(title = "病历表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HzMedical hzMedical)
    {
        return toAjax(hzMedicalService.updateHzMedical(hzMedical));
    }

    /**
     * 删除病历表
     */
    @PreAuthorize("@ss.hasPermi('medical:Medical:remove')")
    @Log(title = "病历表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hzMedicalService.deleteHzMedicalByIds(ids));
    }
}
